#!/usr/bin/bash

for host in `cat list`
do
end=`echo $host | awk -F '.' '{print $4}'`
password="hello.$end"
echo $password
user='root'
/usr/bin/expect << EOF
spawn ssh $user@$host                          
expect "*]#" 
send "echo $password | passwd --stdin root \r"
expect "*]#"
send "exit\r"
EOF
done
